package com.hermit.qmst.UI.activitys;


import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.TabHost;

import com.hermit.qmst.R;
import com.hermit.qmst.UI.main.ContactFragment;
import com.hermit.qmst.UI.main.FragmentTabHost;

public class ContactActivity extends FragmentActivity {

    //创建数据存放Fragment
    private Class mFragmentArray[] = {ContactFragment.class};

    //下面两个数组并没有真正显示出来
    private int mImageViewArray[] = {R.drawable.tabbar_3};
    private String mTextViewArray[] = {"联系人"};

    private FragmentTabHost mTabHost;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
    }

    private void initView() {
        //初始化tabhost
        setContentView(R.layout.activity_tab_main);
        findViewById(R.id.tabbar).setVisibility(View.GONE);
        mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
        mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
        mTabHost.getTabWidget().setDividerDrawable(android.R.color.transparent);
        int count = mFragmentArray.length;

        for (int i = 0; i < count; i++) {

            TabHost.TabSpec tabSpec = mTabHost.newTabSpec(mTextViewArray[i])
                    .setIndicator(mTextViewArray[i], getResources().getDrawable(mImageViewArray[i]));
            mTabHost.addTab(tabSpec, mFragmentArray[i], null);

        }
        //设置当前fragment
        mTabHost.setCurrentTab(0);
    }

}
